package com.qf.service;

import redis.clients.jedis.Jedis;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author lixu
 */
public class LockDemo2 {

    //
    private static final Lock lock = new ReentrantLock();//高级内存 JUC 多线程




/*    public static void main(String[] args) throws Exception{

        //lock.lock();//不见不散的锁

        Jedis jedis = new Jedis();
        Long lo = jedis.setnx("lock", "123");//上锁
       // boolean lo = lock.tryLock(1, TimeUnit.SECONDS);//过期不候的锁
        if(lo == 1){
            //在1s之内获取到了锁
            // 大约过来一个人 查询DB 保存Redis
        }else{
            //未获取到锁
            //直接再次查询Redis

        }


    }*/

    public static void main(String[] args) {


        String key = "2206";
        int i = key.hashCode();
        int i1 = i % 16386;//  0~16385
        System.out.println(i1);
    }
}
